<!DOCTYPE html>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="/common/commonCss.jsp"/>
<link href='${basePath}commonCss/css/fullcalendar-tuanti.css' rel='stylesheet' />
<link href='${basePath}commonCss/css/fullcalendar.print-tuanti.css' rel='stylesheet' media='print' />
<link rel='stylesheet' href='${basePath }commonCss/css/jquery-ui.min.css' />
<link href='${basePath }commonCss/css/fullcalendar-tuanti.css' rel='stylesheet' />
<link href='${basePath }commonCss/css/fullcalendar.print-tuanti.css' rel='stylesheet' media='print' />
<link rel="stylesheet"   type="text/css" href="${basePath }commonCss/css/baseDatePicker/ui.all.css" />
<script  type="text/javascript" src="${basePath }commonJs/message.js"></script>
<script  type="text/javascript" src="${basePath }commonJs/jt_map.js"></script>
 <script  type="text/javascript" src="${basePath }commonJs/jquery.min.js"></script>
<script  type="text/javascript" src="${basePath }commonJs/jquery.easyui.min.js"></script>
<script type="text/javascript" src='${basePath }commonJs/lib/moment.min.js'></script>
<script type="text/javascript" src="${basePath }commonJs/jquery.min.js"></script>
<script type="text/javascript" src='${basePath }commonJs/lib/jquery-ui.custom.min.js'></script>
<script type="text/javascript" src='${basePath }commonJs/fullcalendar_tuanti.js'></script>
<script type="text/javascript" src='${basePath }commonJs/lang-all.js'></script>
<script type="text/javascript" src='${basePath }commonJs/jquery.fancybox-1.3.1.pack.js'></script>
<script type="text/javascript" src="${basePath }commonJs/jt_normal.js"></script>
 <script  type="text/javascript" src="${basePath }commonJs/jt_select.js"></script>
<script type="text/javascript" src="${basePath }commonJs/ui/ui.core.js"></script>
<script type="text/javascript" src="${basePath }commonJs/ui/ui.datepicker.js"></script>
<script type="text/javascript" src="${basePath }commonJs/ui/ui.datepicker-zh-CN.js"></script>
<script type="text/javascript" src="${basePath }commonJs/jquery.form.min.js"></script>

<script type="text/javascript" src="${basePath}commonJs/file_group.js"></script>
<script type="text/javascript" src="${basePath }commonJs/calendar.js"></script>
<script  type="text/javascript" src="${basePath }commonJs/tags/page/page.js"></script>
<script type="text/javascript" src="${basePath }commonJs/tags/My97DatePicker/WdatePicker.js"></script>


<script type="text/javascript">
var roomArray=null;
var fangArray=[];
var parReDateArray=[];
var fanglength =0;
var baseLocalPath='${basePath }';
var basePath = "${basePath}";
//var jiawu=new Array("0wufang-","1tangguo-","2tuhua-","3qixiu-","4gongneng-");//声明 房屋类型 数组 4657
var parStatus=new Array("未预付","自动取消","取消","待确认","已确认","进行中","完成","删除");
$(document).ready(function() {
	var date = new Date();
	var year = date.getFullYear();
	var month = date.getMonth()+1;
	var day = date.getDate();
	day="dd".replace(/dd|DD/,day>9?day.toString():'0' + day);   
	day=year+'-'+month+'-'+day;
	var  indexFlag ='${indexflag}';
	if(""!=indexFlag&& indexFlag ==2){
		$("#grpFlag").val("1");//团体
	}
	loadBrans();
	initrili();
	renderCalendar(day);
	 $("#selectDate").val(day);
	initTab("form1", "table1", "foot1", initData);
});
//点击时间获取预约信息
function  getInfo(dp){
	if(checkIsNull(dp.cal.getNewDateStr())){
		return;
	}else{
		$('#calendar').fullCalendar('destroy');
		renderCalendar(dp.cal.getNewDateStr());
	}
}
function initrili(){
	$("#modiBy").val('${userIddq}');
	$("#fkBranId").val('${branIddq}');
	getparRoomList();
	  roomArray= new   Array();    
	<c:forEach items="${listRoom}" var="parRoom" varStatus="status">
	  roomArray['${status.index}']='${parRoom.roomName}-';
	</c:forEach>
		fanglength =roomArray.length;
		var customerDate = parReDateArray[0];
		$('#calendar').fullCalendar('destroy');
		$("#fkBranIdhedden").val($("#fkBranId").val());
		renderCalendar(customerDate);
		$("#selectDate").val(customerDate);
		refreshSelect();
}
function initTab(formId, tableId, footId, initTr) {
	var form = $("#" + formId);
	var pagebean = new PageBean(form);
	pagebean.setCallback(initTr);
	pagebean.setFootId(footId);
	pagebean.setTableId(tableId);
	setPagebeanObj(pagebean);
	pagebean.doPage();
}

function quearyList(){
	$("#fkBranIdhedden").val($("#fkBranId").val());
	 var subject =$("#subject").val();
	 var resTimeS =$("#resTimeS").val();
	 var resTimeE =$("#resTimeE").val();
	 var grpFlag =$("#grpFlag").val();
	 var modiBy =$("#modiBy").val();
	 var resStatus =$("#resStatus").val();
		 $("#subjectList").val(subject);
		 $("#resTimeSList").val(resTimeS);
		 $("#resTimeEList").val(resTimeE);
	 if(grpFlag!=""){
		 $("#grpFlagList").val(grpFlag);
	 }
		 $("#modiByList").val(modiBy);
		 $("#resStatusList").val(resStatus);
	if(document.getElementById("preBut").style.display=="block"){
		initrili();
	}else{
		 initTab("form1", "table1", "foot1", initData);
	}
}

function getparRoomList(){ //查询 预约房间列表，在 日历控件 模式中显示  
	 var url ='${basePath }parreserve/findParReserveRooMList.shtml';
	$.ajax({
		   url: url,
		   type: 'POST',
		   data:$("#formView").serialize(),//序列化表单里所有的内容
		   async:false, 
		   error : function(XMLHttpRequest) {
			   ajaxError(XMLHttpRequest);
			   },
		   success:function(data){
				if (data != null) {
					var jsonarray ;
					fangArray=[];
					 for(var o in data){
						 if(o=="parResDateList"){
							 parReDateArray=data[o];
						 }
						 if(o=="gblparResRoomMap"){
							 jsonarray=data[o];
							// var obj = str.parseJSON(); start: '2014-06-12T10:00:00',
					//end: '2014-06-12T12:00:00'
							 for (var k = 0; k < jsonarray.length; k++){
								 fangArray.push();
								 var jsonobj = jsonarray[k];
								 var statusInt=jsonobj["resStatus"];
								 var parStatusName=parStatus[statusInt-1];
								 var subject=jsonobj["subject"];
								 var conName=jsonobj["conName"];
								 if(conName==null){
									 conName ="";
								 }
								 if(subject==null){
									 subject ="";
								 }
								 if(subject.length>12){
									 subject =subject.substring(0,12)+"...";
								 }
								 
								 if(conName.length>12){
									 conName =conName.substring(0,12)+"...";
								 }
								 var fangid=jsonobj["roomName"]+"-"+jsonobj["roomId"]+"@"+jsonobj["lockFlag"];
								 var partitle=jsonobj["roomName"]+"-"+parStatusName+"\n"+subject+"\n"+conName+" "+jsonobj["conMobile"];
								 var parStart=jsonobj["presDay"]+"T"+jsonobj["resTimeS"];
								 var parEnd=jsonobj["presDay"]+"T"+jsonobj["resTimeE"];
								 var grpFlag =jsonobj["grpFlag"]; 
								 var pkParresId =jsonobj["pkParresId"];
								 var  detailUrl='${basePath }parreserve/parReserveManagesDetail.shtml?pkParresId='+pkParresId+'&grpFlag='+grpFlag;
								 var testJson = { "id": fangid, "title":partitle,"start":parStart,"end":parEnd,"url":detailUrl};
								 fangArray.push(testJson);
								  
							 }
							 
						 }
					 }
				}else{
					 alertError('加载预约房间失败！');
				}
		   }
		  });
}
var oldDateIndex=0;
function qtyUpdate(kind){// 上一条，下一条 按钮 ，操作 
	var maxLength=0;
	if( parReDateArray.length>1){
		maxLength= parReDateArray.length-1;
	}
    if(kind == "next"){
    	$('#preBut').removeAttr("disabled");
    	 $('#preBut').removeClass().addClass("btn fr ml10");
    	 if(oldDateIndex== maxLength){//初始化 加载页面时，只能点击 上一条 按钮。
         	//alertWarning('请先点击 上一条 按钮！');
    		   $('#nextBut').attr('disabled',"true");
			   $('#nextBut').removeClass().addClass("btn_no fr ml10");
              return;
         }else{
        	 oldDateIndex++;
         }
    }else if(kind == "pre"){
    	 $('#nextBut').removeAttr("disabled");
  	      $('#nextBut').removeClass().addClass("btn fr ml10");
        if(oldDateIndex==0){//初始化 加载页面时，只能点击 上一条 按钮。
        	//alertWarning('请先点击 下一条 按钮！');
        	  $('#preBut').attr('disabled',"true");
        	  $('#preBut').removeClass().addClass("btn_no fr ml10");
             return;
        }else if(oldDateIndex > 0){
        	
        	oldDateIndex--;
        }
    }
    $('#calendar').fullCalendar('destroy');
    var setDaten = parReDateArray[oldDateIndex];//点击 上一条，下一条，根据 日期 控制 大日历控件，
    //setdatepicker(setDaten,true);
    $("#selectDate").val(setDaten);
    renderCalendar(setDaten);
}

function initData(data) { //初始化预约 列表
	if(data!=null){
		var parStatus=new Array("未预付","自动取消","取消","待确认","已确认","进行中","完成","删除");
		$.each(data,function(ind,obj){
			var htm="<tr>";
			var userNameo=obj.userName;
			if(userNameo==null){
				userNameo="";
			}
			 var  detailUrl='${basePath }parreserve/parReserveManagesDetail.shtml?pkParresId='+obj.pkParresId+'&grpFlag='+obj.grpFlag;
			var statusValue =obj.resStatus;
			htm+='<td class="lv"><a href="'+detailUrl+'">'+obj.pkParresId+'</a></td>';
			htm+="<td>"+obj.subject+"</td>";
			htm+="<td>"+parStatus[statusValue-1]+"</td>";
			htm+="<td>"+obj.presDay+" "+obj.resTimeS+"-"+obj.resTimeE+"</td>";
			htm+="<td>"+obj.conName+"</td>";
			htm+="<td>"+obj.conTel+"</td>";
			htm+="<td>"+obj.conMobile+"</td>";
			htm+="<td>"+userNameo+"</td>";
			htm+="</tr>";
			 $("#table1").find("tr:eq("+ind+")").after(htm);
		});
	}
}
function conView(type){
	if(type=="conView"){
		 document.getElementById("preBut").style.display="block";
		 document.getElementById("nextBut").style.display="block";
		 document.getElementById("yuyueriqiwen").style.display="block";
		 
	}else{
		 document.getElementById("preBut").style.display="none";
		 document.getElementById("nextBut").style.display="none";
		 document.getElementById("yuyueriqiwen").style.display="none";
	}
	
}

/**
 * 加载门店信息
 */
function loadBrans(){
	 $.ajax({  
	        type: 'get',  
	        url: "${basePath}filemanagement/listAllBran.shtml",  
	        cache: false,
	        async: false,
	        dataType: 'json',  
	        error : function(XMLHttpRequest) {
	        	ajaxError(XMLHttpRequest);
	        	},
	        success: function(branList){ 
	        	$(branList).each(function(n){
	        		if("全部"!=this.branName){
	        			$("#fkBranId").append("<option value='"+this.pkBranId+"'>"+this.branName+"</option>");
	        		}
		        });
	        },  
	        error: function(){  
	            return;  
	        }  
	    });  
}
</script>
 
 
 
<title>首页</title>
</head>
<body class="bg">


<div class="content m_auto">
	<div class="content_l mt10">
    	<ul>
    	 <shiro:hasPermission name="filemanagement/listVip.shtml?type=1">
        	<li><a href="${basePath}filemanagement/listVip.shtml?type=1"><i class="nav_icon_b"></i><br>会员管理</a></li>
        	</shiro:hasPermission>
        	 <shiro:hasPermission name="filemanagement/viewVistors.shtml?type=3">
            <li><a href="${basePath}filemanagement/viewVistors.shtml?type=3"><i class="nav_icon_d"></i><br>访客管理</a></li>
            </shiro:hasPermission>
             <shiro:hasPermission name="filemanagement/listViewSingelTicket.shtml?type=2">
            <li><a href="${basePath}filemanagement/listViewSingelTicket.shtml?type=2"><i class="nav_icon_a"></i><br>非会员管理</a></li>
            </shiro:hasPermission>
             <shiro:hasPermission name="parreserve/parReserveManages.shtml?indexflag=">
            <li class=" content_hover"><a href="${basePath }parreserve/parReserveManages.shtml?indexflag="><i class="nav_icon_g"></i><br>预约管理</a></li>
            </shiro:hasPermission>
             <shiro:hasPermission name="filemanagement/customer/serviceList.shtml">
             <li><a href="${basePath}filemanagement/customer/serviceList.shtml"><i class="nav_icon_h"></i><br>客户服务</a></li>
             </shiro:hasPermission>
              <shiro:hasPermission name="crm/jumpCrm.shtml">
            <li><a href="${basePath}crm/jumpCrm.shtml"><i class="nav_icon_n"></i><br>客户关系管理</a></li>
            </shiro:hasPermission>
        </ul>
    </div>
    <div class="content_r mt10">
    	<div class="p20">
    	<form action="" method="post" id="formView">
    	 <div class="file_single_dl f14 fixed">
        	<dl class="fixed" style="overflow:hidden">
            	<dd><label>联系人\手机\主题：</label><input type="text" name="subject" id="subject" class="iput_t w200">
            	   <input type="hidden" name="indexflag"   value="${indexflag}"  >
            	</dd>
                <dd><label>时间：</label><input title="" type="text" name="resTimeS" id="resTimeS"
					onClick="WdatePicker({dateFmt:'yyyy-MM-dd ',isShowWeek:true,isShowClear:true,readOnly:true,maxDate:'#F{$dp.$D(\'resTimeE\')}'})"
					class="Wdate iput_t w82" readonly /><span class="mlr5">至</span><input title="" type="text" name="resTimeE" id="resTimeE"
					onClick="WdatePicker({dateFmt:'yyyy-MM-dd ',isShowWeek:true,isShowClear:true,readOnly:true,minDate:'#F{$dp.$D(\'resTimeS\')}'})"
					class="Wdate iput_t w82" readonly /></dd>    	
                
                 <dd><label>类型：</label>
                	<div class="uboxstyle">
                        <select name="grpFlag" id="grpFlag">
                        	<option value="" >全部</option>
                            <option value="0">派对预约</option>
                            <option value="1">团体预约</option>
                        </select>
                    </div>
                </dd>
                <dd><label>关联专员：</label>
                	<div class="uboxstyle">
                        <select name="modiBy" id="modiBy">
                            <option value="">全部</option>
                            <c:forEach items="${listuserPar}" var="userP" >
                            <option value="${userP.pkUsrId}">${userP.usrName}</option>
                            </c:forEach>
                             
                        </select>
                    </div>
                </dd>
                <dd><label>状态：</label>
                	<div class="uboxstyle">
                        <select name="resStatus" id="resStatus">
                            <option value="">请选择</option>
                            <option value="1">未预付</option>
                            <option value="2">自动取消</option>
                            <option value="3">取消</option>
                            <option value="4">待确认</option>
                            <option value="5">已确认</option>
                            <option value="6">进行中</option>
                            <option value="7">完成</option>
                            <!-- <option value="8">删除</option>  -->
                        </select>
                    </div>
                </dd>
                <dd><label>所属门店：</label>
                    <div class="uboxstyle">
                       <select id="fkBranId" name="fkBranId">
								</select>
                    </div>
                </dd>
            </dl>
            <div class="file_single_dl">

            	<input type="button" class="btn fr ml10" onClick="quearyList()" value="查询">
                <input type="button" class="btn fr ml10" id="preBut" style="display:block" onclick="qtyUpdate('pre')" value="上一条">
                <input type="button" class="btn fr ml10" id="nextBut" style="display:block" onclick="qtyUpdate('next')" value="下一条">
                <c:choose>
	                <c:when test="${branIddq=='ZB'}"></c:when>
	                <c:otherwise>
	                <input type="button" class="btn fr ml10" onClick="window.location.href='${basePath }parreserve/tuanReserveDetail.shtml?parType=1&pkParresId=&pkOrderId='" value="派对/团体预约">
	           		</c:otherwise>
           		</c:choose>
            </div>
        </div>
        </form>
        <div class="tab_normal mt10">
            <ul class=" fixed" id="tab_a">
            	<li id="conView" class="thistab_a" onclick="conView('conView')">视图样式</li>
                <li id="conList" onclick="conView('conList')">列表样式</li>  
                <dl id="yuyueriqiwen">
                	<dd>
                    	<label>预约日期：</label>
                    	<input type="text" title="" name="date1" id="selectDate" onFocus="WdatePicker({onpicking:function(dp){getInfo(dp);}});" class="Wdate iput_t w150" readonly="readonly">
                     </dd>
                </dl>                 
            </ul>
          	<ul class="fixed" id="tab_conbox_a">
            	 <li class="p10">	
                	<div class="collection_b">
	                		<div id='calendar' class="data_l data_l_r"></div>
	      				  <!-- <div class="data_r mt10" id="calendarInput"></div> -->
                         <!---<a href="file_liet_t.html"><img src="${basePath}commonCss/images/tuanti.png"></a>  ---->
                    </div>
                </li>
                <li class="p10 h450">
                <form action="${basePath }parreserve/parReservePageListManages.shtml" method="post" id="form1">
                  <input type="hidden" name="pageSize" value="10"> 
                  <input type="hidden" name="pageNo" value="1">
                  <input type="hidden" name="indexflag"   value="${indexflag}"  > 
                   <input type="hidden" name="subject" id="subjectList"  > 
                   <input type="hidden" name="resTimeS"  id="resTimeSList">  
                    <input type="hidden" name="resTimeE" id="resTimeEList"> 
                    <input type="hidden" name="grpFlag" id="grpFlagList">
                        <input type="hidden" name="fkBranId" id="fkBranIdhedden">
                     <input type="hidden" name="modiBy" id="modiByList"> 
                     <input type="hidden" name="resStatus" id="resStatusList">  
                      <input type="hidden" name="menda" value="10">  
                	<table class="table" id="table1">
                    	<tr>
                        	<th>编号</th>
                            <th>主题</th>
                            <th>状态</th>
                            <th>时间</th>
                            <th>联系人</th>
                            <th>固话</th>
                            <th>手机</th>
                            <th>专员</th>
                        </tr>
                         
                    </table>
                    </form>
                    <!---翻页-->
                       <div class="page fr m10" id="foot1">
						
						</div>
                    <!----->
                </li>
               
			</ul>
    	</div>
        </div>
    </div>
</div>

 
</body>
</html>